# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html


class CsdnPipeline(object):
    def process_item(self, item, spider):
        name = item["name"]
        teacher = item["teacher"]
        stu_cnt = item["stu_cnt"]
        price = item["price"]
        times = item["times"]

        filename = "course\\course_"+str(name)+".txt"
        fh = open(filename, "w")        
        fh.write("课程名称: " + str(name)+"\n")
        fh.write("授课老师: " + str(teacher)+"\n")
        fh.write("学员数量: " + str(stu_cnt)+"\n")
        fh.write("课程价格: " + str(price)+"\n")
        fh.write("课程课时: " + str(times)+"\n")
        fh.close()

        return item

